package com.jinzhuo.music.service;

import com.jinzhuo.music.dao.SongMapper;
import com.jinzhuo.music.domain.Song;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 歌曲实现类
 */
@Service
public class SongServiceImpl implements SongService {
    @Autowired
    private SongMapper songMapper;
    /**
     * 添加
     *
     * @param pojo
     */
    @Override
    public boolean addSong(Song pojo) {
        return songMapper.addSong(pojo)>0;
    }

    /**
     * 修改
     *
     * @param pojo
     */
    @Override
    public boolean updateSong(Song pojo) {
        return songMapper.updateSong(pojo)>0;
    }

    /**
     * 删除
     *
     * @param id
     */
    @Override
    public boolean deleteSong(Integer id) {
        return songMapper.deleteSong(id)>0;
    }

    /**
     * 根据主键查询单个对象
     *
     * @param id
     */
    @Override
    public Song getSong(Integer id) {
        return songMapper.getSong(id);
    }

    /**
     * 查询所有歌曲
     */
    @Override
    public List<Song> queryAllSong() {
        return songMapper.queryAllSong();
    }

    /**
     * 根据歌名查询歌曲
     *
     * @param name
     */
    @Override
    public List<Song> querySongByName(String name) {
        return songMapper.querySongByName(name);
    }

    /**
     * 根据歌手名模糊查询歌曲
     *
     * @param name
     */
    @Override
    public List<Song> querySongLikeName(String name) {
        return songMapper.querySongLikeName("%"+name+"%");
    }

    /**
     * 根据歌手id查询歌手
     *
     * @param singerId
     */
    @Override
    public List<Song> querySongBySingerId(Integer singerId) {
        return songMapper.querySongBySingerId(singerId);
    }
}
